<?php 
/**
 * @Author: Kendy
 * @Date:   2019-11-11 09:08:15
 * @Last Modified by:   jiayanting
 * @Last Modified time: 2020-03-26 10:45:11
 */
namespace app\api\model; 
use think\Model;
use think\Db; 
use app\common\model\GuideModel as g;
use app\api\model\GroupTour as gt; 
class Customization extends Model
{
	public function getCusPage()
	{
		$where['is_del'] = array('eq', 0);
		$where['is_pass'] = array('eq', 1);
		$where['is_recommend'] = array('eq', 1);
		//旅行社精选
		$resultData['team_recomment'] = Db::name('team')
		->field('team_id,team_icon,team_name')
		->where($where)
		->limit(3)
		->select();
        //私人导游  
        $where1['is_del'] = 0;
        $where1['is_pass'] = 1;
        $where1['is_recommend'] = 1;
        $guide = new g();
        $resultData['guide_list'] = $guide->getGuideList($where,1,3,'guide_id,guide_head,name,guide_tag,examine_time,app_time,guide_rank');
        if(count($resultData['guide_list'])>0)
        {
        	foreach ($resultData['guide_list'] as $k => $v) {
        		$resultData['guide_list'][$k]['guide_tag'] = explode(',', $v['guide_tag']);
        		 if($v['guide_rank']==1)$resultData['guide_list'][$k]['guide_rank'] = '金牌导游';
        		 elseif($v['guide_rank']==2)$resultData['guide_list'][$k]['guide_rank'] = '优质导游';
        		 else $resultData[$k]['guide_rank'] = '';
        	}
        }
        $groupTour = new gt();
        $wheres['is_del'] = 0;
        $fs = [];
        //猜你喜欢
         $resultData['gtour_list'] = $groupTour->GetGroupTourList($wheres,$fs,0,3,'');  
       return apiReturn('200','成功',$resultData); 
	}

    /**
     * [getGtourListById 通过id获取旅行社的跟团产品]
     * @Author   kendy
     * @DateTime 2019-11-14T10:07:18+0800
     * @return   [type]                   [description]
     */
	public function getGtourListById($team_id)
	{  
        $orderBy = input("post.orderBy");
        $orderBy = empty($orderBy)?0:$orderBy; 
		$resultData['team'] = Db::name('team')
		->field('team_id,team_name,team_icon,team_background')
		->where(['is_del'=>0,'is_pass'=>1,'team_id'=>$team_id])
		->find();
		if(empty($resultData['team']))
			 return apiReturn('400','无效的旅行社',0); 
         // 店铺的收藏人数
         $resultData['team']['collect'] =  Db::name('collect') 
            ->where(['type'=>3,'other_id'=>$team_id])
            ->count();
	     $gt = new gt();
	     //旅行社信息 
	     $where['is_del'] = 0; 
	     $where['team_id'] = $team_id;   
         $page = (input('post.page/d','1','trim')-1)*config('page_size'); 
	     $resultData['gtour_list'] = $gt->GetGroupTourList($where,'',$page,'',$orderBy); 
         return apiReturn('200','成功',$resultData);    
	}

}